<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
	<?php
		echo "Compra ingresso - $_POST[filme]";
	?>
</title>
</head>

<style type="text/css">

	body {
		background-color: #8cd6dd;
		font-family:"Courier New", Courier, monospace;
		font-size:12px;
	}
	
	.titles {
		font-weight:bold;
		font-size:16px;	
		text-align:center;
		
	}

</style>
<script type="text/javascript">

	var w = document.width;
	var h = document.height;
	
	window.moveTo(w / 2, h / 2);
</script>
<body>
<table align="center" style="margin-top:50px;margin-bottom:50px">
	<tr>
    <td><span class="titles"> Tem certeza que deseja comprar? </span>
    </td>
</tr>
<tr><td><br /></td></tr>
<tr>
<?php
                
                    require_once("php/config.php");
                    require_once("php/postgres.php");
                    
                    try {
                        
                        $confs = $GLOBALS["CONFIGS"]["PSQL_DB"];
                        $pgcon = new PostgresConnection($confs["HOST"], $confs["PORT"], $confs["USER"], $confs["PASSWORD"], $confs["DATABASE"]);
						$cliente = $pgcon->getClient($_COOKIE["checkLogin"]);
						$preco = 0;
						$nome = $cliente["pre_nome"];
						$ingressos = $pgcon->getAllTickets();
						
						$pdata = new DateTime(str_replace("/","-", $_POST["data"]));
						$d = $pdata->format("N");
						switch ($d) {
						
							case '1':
							
								$dia = "dom";
								break;
									
							case '2':
								
								$dia = "seg";
								break;
									
							case '3':
							
								$dia = 'ter';
								break;
								
							case '4':
							
								$dia = 'qua';
								break;
								
							case '5':
								
								$dia = 'qui';
								break;
								
							case '6':
								
								$dia = 'sex';
								break;
								
							case '7':
							
								$dia = 'sab';
								break;
						}
						$tipoingresso = "preco_meia";
						
						if ($_POST['ingresso'] == "Inteira - Adulto")	{
							
							$tipoingresso = "preco_inteira";
						}
						
//						$ingressos["seg"]["preco_inteira"];
						
    					echo'<td align="center">
								<span>N&uacute;mero do cart&atilde;o de cr&eacute;dito cadastrado: '. $cliente["cartao_credito"] .'</span>
								<br />
								<span>Nome do titular: '. $cliente["nome_titular"] .'</span>
								<br />
								<span>Valor do ingresso: R$ ' . $ingressos[$dia][$tipoingresso] * 1.1 . '</span>
							</td>';
						
	                    
						
						} catch (PostgresConnectionException $pce) {
                        
                        echo "<span style='color:red;'>Desculpa, mas sua requisi&ccedil;&atilde;o n&atilde;o pode ser processada agora. Volte mais tarde.</span>";
                    }
                    
                    
                    
                ?>
</tr>
<tr>
    	<td align="center">
        <br />
        	<form id="confirmform" action="ticket.php" method="post">
            <input name="filme" id="filme" type="hidden" value= "<?php echo $_POST['filme'] ?>"/>
            <input name="ingresso" id="ingresso" type="hidden" value= "<?php echo $_POST['ingresso'] ?>"/>
            <input name="data" id="data" type="hidden" value="<?php echo $_POST['data'] ?>"/>
			<input name="hora" id="hora" type="hidden" value="<?php echo $_POST['hora'] ?>"/>
            <input name="prenome" id="prenome" type="hidden" value="<?php echo $nome ?>"/>
            <input name="preco" id="preco" type="hidden" value= "<?php echo $ingressos[$dia][$tipoingresso] * 1.1; ?>"/>
            <input type="submit" value="Sim" />
            <input type='button' onclick='window.close()' value='N&atilde;o' />
            </form>
        <br />
        <!--<td><input type='button' onclick='javascript:history.back();self.location.reload();' value='N&atilde;o' /> -->
        
        </td>
    </tr>
</table>

</body>
</html>